-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Only setup shared pools if we have a connection #45773
Merged
eileencodes
merged 1 commit into
rails:main
from
eileencodes:only-setup-shared-pools-if-we-have-a-connection
Aug 5, 2022
Merged
Only setup shared pools if we have a connection #45773
eileencodes
merged 1 commit into
rails:main
from
eileencodes:only-setup-shared-pools-if-we-have-a-connection
Aug 5, 2022
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Previously `setup_shared_connection_pool` was called anytime `setup_fixtures` saw a future connection established. Sometimes those connections are `nil` but we were setting up the shared pools before determining that. This change moves the `setup_shared_connection_pool` into the check for if we have a connection. The tests that were dealing with these settings were originally set to not use transacitons. But without this we can't test the change here so I've updated that as well. This is an alternate fix to rails#45769. I realized after opening the PR it wasn't quite right to skip if we don't have a writing pool config, because the question is how were we ending up with that anyway? Well the answer was that we were calling the shared setup in the wrong place. Fixes rails#45767
eileencodes
added a commit
that referenced
this pull request
Aug 5, 2022
…-we-have-a-connection Only setup shared pools if we have a connection
I backported this to 7-0-stable and pushed before I realized one legacy connection handling test is failing. Working on a fix, if I can't find one I'll revert the one on 7-0-stable. |
eileencodes
added a commit
that referenced
this pull request
Aug 5, 2022
PR #45773 broke legacy handling test fixtures and while I can fix this particular error it breaks how shared pools are setup. I don't think this is the same kind of buggy on legacy handling so let's leave that behavior and only change the new handling.
eileencodes
added a commit
that referenced
this pull request
Aug 5, 2022
…-we-have-a-connection Only setup shared pools if we have a connection
eileencodes
added a commit
that referenced
this pull request
Aug 5, 2022
PR #45773 broke legacy handling test fixtures and while I can fix this particular error it breaks how shared pools are setup. I don't think this is the same kind of buggy on legacy handling so let's leave that behavior and only change the new handling.
eileencodes
added a commit
that referenced
this pull request
Aug 5, 2022
* In 7-0-stable it's `ActiveRecord.legacy_connection_handling` but in 6-0-stable it's `ActiveRecord::Base.legacy_connection_handling`. * I don't really get why but since the transactional tests line was removed the lines calling `establish_connection(:primary)` started raising the deprecation warning saying that Base and primary won't be treated the same in the future so I added some assertion blocks around those.
Backported to 7-0-stable and 6-1-stable but note this is only handled for the new connection handling and not legacy handling. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously
setup_shared_connection_pool
was called anytimesetup_fixtures
saw a future connection established. Sometimes thoseconnections are
nil
but we were setting up the shared pools beforedetermining that.
This change moves the
setup_shared_connection_pool
into the check forif we have a connection. The tests that were dealing with these settings
were originally set to not use transacitons. But without this we can't
test the change here so I've updated that as well.
This is an alternate fix to #45769. I realized after opening the PR it
wasn't quite right to skip if we don't have a writing pool config,
because the question is how were we ending up with that anyway? Well the
answer was that we were calling the shared setup in the wrong place.
Fixes #45767